package com.yang.controller;

import com.yang.entity.OrderDetails;
import com.yang.entity.OrderItem;
import com.yang.entity.Result;
import com.yang.service.OrderService;
import com.yang.utils.ThreadLocalUtil;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Resource
    private OrderService orderService;

    @GetMapping("/orderList")
    public Result<List<OrderDetails>> getOrderList(){
        System.out.println("orderList =====>");
        // 获取用户id
        Map<String,Object> map= ThreadLocalUtil.get();
        Integer userId = (Integer) map.get("userId");
        List<OrderDetails> orderList = orderService.getOrderList(userId);
        return Result.success(orderList);
    }

}
